package MVC;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public abstract class View {

    /* Atributos */
    public static JFrame frame;
    public static JMenuBar menuBar;
    public static JMenu fileMenu;

    /* Métodos */
    public void open() {

        //frame
        frame = new JFrame("Pentago");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.pack();

        //menuBar
        menuBar = new JMenuBar();

        //fileMenu
        fileMenu = new JMenu("File");

        //item
        JMenuItem quitMenuItem = new JMenuItem("Quit");
        quitMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                quit();
            }
        });

        fileMenu.add(quitMenuItem);
        menuBar.add(fileMenu);
        frame.setJMenuBar(menuBar);
    }

    public void show() {
        frame.setVisible(true);
    }

    public void hide() {
        frame.setVisible(false);
    }

    public void quit() {
        frame.dispose();
    }

    public void alert(String msg) {
        JOptionPane.showMessageDialog(frame, msg);
    }

    public abstract void rendered();

    public abstract JPanel mainPanel();

}
